<template>
  <t-dialog :header="header" :confirmBtn="null" :visible.sync="visible" :onClose="closeDialog"
            :closeOnOverlayClick="false"
            width="80%" top="5%">
    <div style="height: 65vh">
      <t-table row-key="id" :columns="columns" :data="data"
               :loading="dataLoading">
        <template #name="{ row }">
          <t-link @click="dialog.objId=row.id;dialog.header=row.name;dialog.open_innovation_detail=true" hover="color" theme="primary">{{row.name}}</t-link>
        </template>
        <template #applicationField="{row}">
          {{ row.applicationField | filterByDict(dict.type.application_field) }}
        </template>
        <template #innovationCategory="{row}">
          {{ row.innovationCategory | filterByDict(dict.type.innovation_category) }}
        </template>
        <template #innovationStatus="{ row }">
          <t-tag  @click="dialog.header='审批记录';dialog.objId=row.id;dialog.open_approve_list=true" class="cursor-pointer" :theme="handleTheme(row.innovationStatus, dict.type.innovation_status)" variant="light">
            {{ row.innovationStatus | filterByDict(dict.type.innovation_status) }}
          </t-tag>
        </template>
        <template #[`xsReviewStatus`]="{ row }">
          <t-tag v-if="row.xsReviewStatus" @click="dialog.header=row.name;dialog.objId=row.id;dialog.open_approve_list=true" class="cursor-pointer" :theme="handleTheme(row.xsReviewStatus, dict.type.xs_review_status)" variant="light">
            {{ row.xsReviewStatus | filterByDict(dict.type.xs_review_status) }}
          </t-tag>
          <t-tag @click="dialog.header=row.name;dialog.objId=row.id;dialog.open_approve_list=true" class="cursor-pointer" v-else theme="warning" variant="light">未评审</t-tag>
        </template>
        <template #op="{row}">
          <t-button
            @click="dialog.header=row.name;dialog.objId=row.id;dialog.editOpen=false;dialog.open_detail=true"
            size="small" variant="text" class="t-button-link">
            <t-icon name="info-circle" slot="icon"/>
            详情
          </t-button>
        </template>
      </t-table>
      <innovation-detail-dialog :header="dialog.header" :objId="dialog.objId" :visible.sync="dialog.open_innovation_detail" v-if="dialog.open_innovation_detail"></innovation-detail-dialog>

      <approve-list :header="dialog.header" :objId="dialog.objId" :visible.sync="dialog.open_approve_list"
                    v-if="dialog.open_approve_list"></approve-list>
    </div>
  </t-dialog>
</template>

<script>
import ApproveList from "./approve-list.vue";
import innovationDetailDialog from "../../innovation/components/innovation-detail-dialog.vue";

export default {
  name: "show-approver-project",
  dicts: ["application_field", "innovation_category", "approve_status", "innovation_status", "xs_review_status"],
  components: {
    ApproveList,
    innovationDetailDialog
  },
  props: ["userId","header"],
  data() {
    return {
      visible: true,
      dataLoading: false,
      data: [],
      dialog: {
        header: "",
        objId: 0,
        open_detail: false,
        editOpen: true,
        open_approve_list: false,
        open_innovation_detail: false,
      },
      columns: [
        {
          colKey: "name",
          title: "成果名称",
          align: "center",
          width: 220

        },
        {
          colKey: "applicationProject",
          title: "应用项目",
          align: "center",
        },
        {
          colKey: "applicationField",
          title: "应用领域",
          align: "center",
        },
        {
          colKey: "innovationCategory",
          title: "创新类别",
          align: "center",
        },
        {
          colKey: "leaderName",
          title: "负责人",
          align: "center",
        },
        {
          colKey: "deptName",
          title: "工作单位",
          align: "center",
        },
        {
          colKey: "innovationStatus",
          title: "成果状态",
          align: "center",
          width:120
        },
        // {
        //   colKey: "approveStatus",
        //   title: "审批状态",
        //   align: "center",
        //   width:120
        // },

        {
          colKey: "createTime",
          title: "申报时间",
          align: "center",
          width: 200
        },
        {
          colKey: "xsReviewStatus",
          title: "形式审查状态",
          align: "center",
          width:120,
          fixed: 'right',
          // sorter: true
        },
      ],
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.dataLoading = true;
      this.$api.wcx.approve.getApproverReviewByUserId(this.userId).then((res) => {
        this.data = res.data;
        this.dataLoading = false;
      }).catch((e) => {
        this.dataLoading = false
        this.$message.error(e.toString());
      });
    },
    closeDialog() {
      this.$emit("update:visible", false);
    },
  }
}
</script>

<style scoped>

</style>
